import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Window 2.2

import "./Common/Compoments"
import "./Config/"
import "./PlugLoader"
import "./InstrumentPanel"

Window {
    id: mainWindow;
    visible: true
    width: 640
    height: 480
    title: qsTr("QML CUS  (QQ:2313828706))");

    property int m_nPlatForm: setting.getPlatForm();

    //QML组件对应关系
    property var pluginPathMap:
    {
        "Loader":"./PlugLoader/MainFrame.qml",
                "SlidingMenu":"SlidingMenu.qml",
                "RecipePanel":"InstrumentPanel/RecipePanel.qml",
                "speedPanel":"InstrumentPanel/SpeedPanel.qml",
                "zhima":"InstrumentPanel/ZhimaCreditPanel.qml"
    }

    property var arrayQmlObj:new Array()
    //当前显示的插件名称
    property var strCurrentPlugName: ""

    //各个window QML实例
    property var windowQmlMap: new Array()

    property var object;
    property var compoment;

    property var g_Colors: Setting.g_Colors
    property var g_Language: Setting.g_Language
    property var setting: Setting

    Component.onCompleted: {
        //        createPlug("zhima");
    }

    Column
    {
        spacing: 4;
        width: parent.width
        height: parent.height

        ZhimaCreditPanel2
        {
            id: zhima;
            width: parent.width
            height: parent.height*0.9
        }
        Slider
        {
            id: sd;
            width: parent.width

            minimumValue: 400;
            maximumValue: 900;
            stepSize: 1;
            value: 723;

            onValueChanged:
            {
                zhima.update(value);
            }
        }
    }

    //    ChartDemo
    //    {
    //        id: chartdemo
    //    }

    //        HeadPortrait
    //        {
    //            id: head;
    //            m_picturePath: "./Config/Skins/Default/Icons/head_picture.png"
    //        }

    //    LQBaseText {
    //        id: txt
    //        text: "这个是Text组件"
    //        width: parent.width
    //        color: "#FFFFFF"
    //    }

    //    LQBaseButton {
    //        id: findBtn
    //        height: 30
    //        anchors.bottom: parent.bottom
    //        m_btnTextValue: "预览"

    //        onSignalLeftClick:{
    //            createPlug("Loader");
    ////            m_mainWindow.visible = false
    //        }
    //        onSignalRightClick: {
    //            object.destroy(2000);
    //            console.log("right clicked")
    //        }
    //    }

    function createPlug(strPluginName)
    {
        var strQmlFile = m_mainWindow.pluginPathMap[strPluginName];
        console.log(strQmlFile)
        compoment = Qt.createComponent(strQmlFile,Component.PreferSynchronous)
        if ( Component.Ready == compoment.status )
        {
            object = compoment.createObject(m_mainWindow)
            console.log("create")
        }
    }
}
